package com.edgar.designpattern.combining.composite;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Flock implements Quackable {
	
	List<Quackable> quackers = new ArrayList<Quackable>();
	
	public void add(Quackable quackable) {
		quackers.add(quackable);
	}

	@Override
	public void quack() {
		Iterator<Quackable> iterator = quackers.iterator();
		while (iterator.hasNext()) {
			Quackable quacker = (Quackable) iterator.next();
			quacker.quack();
			
		}
		
	}

}
